package servlet;

import service.UserService;
import service.impl.UserServiceImpl;
import util.ScannerUtils;

public class UserLogin{
    public void userLogin(String username, String password) throws Exception {
        UserService userService = new UserServiceImpl();
        String idNumber;
        if(username == null){
            System.out.println("please input name");
            String name = ScannerUtils.scannerUtil();
            System.out.println("please input passwordInput");
            String passwordInput = ScannerUtils.scannerUtil();
            idNumber = userService.select(name,passwordInput);
            if(idNumber==null||idNumber.equals("null")){
                System.out.println("登陆失败");
                UserLogin application = new UserLogin();
                application.userLogin(null,null);
            }else{
                System.out.println("登陆成功");
                FunctionList list = new FunctionList();
                list.userlist(idNumber);
            }
        }else{
            idNumber = userService.select(username,password);
            if(idNumber==null||idNumber.equals("null")){
                System.out.println("登陆失败");
            }else{
                System.out.println("登陆成功");
            }
        }
    }

    public static void main(String[] args) throws Exception {
        UserLogin application = new UserLogin();
        application.userLogin(null,null);
    }
}
